home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / plaf / basic / BasicTreeUI$KeyHandler.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  1.5 KB  |  49 lines

  1. package javax.swing.plaf.basic;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import java.awt.event.InputEvent;
  6. import java.awt.event.KeyAdapter;
  7. import java.awt.event.KeyEvent;
  8. import javax.swing.Action;
  9. import javax.swing.KeyStroke;
  10.  
  11. public class BasicTreeUI$KeyHandler extends KeyAdapter {
  12.    // $FF: synthetic field
  13.    private final BasicTreeUI this$0;
  14.    protected Action repeatKeyAction;
  15.    protected boolean isKeyDown;
  16.  
  17.    public BasicTreeUI$KeyHandler(BasicTreeUI var1) {
  18.       this.this$0 = var1;
  19.    }
  20.  
  21.    public void keyPressed(KeyEvent var1) {
  22.       if (this.this$0.tree.hasFocus() && this.this$0.tree.isEnabled()) {
  23.          KeyStroke var2 = KeyStroke.getKeyStroke(var1.getKeyCode(), ((InputEvent)var1).getModifiers());
  24.          if (this.this$0.tree.getConditionForKeyStroke(var2) == 0) {
  25.             ActionListener var3 = this.this$0.tree.getActionForKeyStroke(var2);
  26.             if (var3 instanceof Action) {
  27.                this.repeatKeyAction = (Action)var3;
  28.             } else {
  29.                this.repeatKeyAction = null;
  30.             }
  31.          } else {
  32.             this.repeatKeyAction = null;
  33.          }
  34.  
  35.          if (this.isKeyDown && this.repeatKeyAction != null) {
  36.             this.repeatKeyAction.actionPerformed((ActionEvent)null);
  37.             ((InputEvent)var1).consume();
  38.          } else {
  39.             this.isKeyDown = true;
  40.          }
  41.       }
  42.  
  43.    }
  44.  
  45.    public void keyReleased(KeyEvent var1) {
  46.       this.isKeyDown = false;
  47.    }
  48. }
  49.